import send_msg from '@feidao-factory/send-msg/browser';

const GET_USER_INFO = 'loginservice.getuserinfobysessionid';

export interface IUserInfo {
	_id: string;
	usercode: string;
	user_name: string;
	name_spell: string;
	is_disabled: boolean;
	create_time: number;
	productid: string;
	avatar_path: string;
	avatar_name: string;
	avatar_type: string;
	email: string;
	phone: string;
	last_login_time: number;
	phone_verified: boolean;
	email_verified: boolean;
	is_admin: boolean;
}
/*
 * 获取用户信息
 * @param _action_id 系统参数action_id
 * @param _sessionid 系统参数session_id
 * @param _spaceid 系统参数spaceid
 */
export default function whoami(_action_id: string, _sessionid: string, _spaceid: string) {
	const msg = {};
	return send_msg(GET_USER_INFO, msg, true, false)
		.catch((e) => {
			console.error(`--调用服务${GET_USER_INFO}失败--错误信息---`, e ? e.toString() : '');
			// const err = e ? e.toString() : '';
			return Promise.reject(e);
		}) as Promise<IUserInfo>;
}
